<template>
  <div class="content">
    <dc-header :title="this.currentTitle" :page-to="'/riskAudit'"></dc-header>
    <dc-rank class="head-top" ref="saleRank" :titles="rankTitles" :rankKey="rankKey"
             :param="param" :url="url" :per="routerData.num!=2"></dc-rank>
  </div>
</template>
<script>
  import header from '@/components/header';
  import rankList from '@/components/rankList';
  export default {
    components: {
      'dc-header': header,
      'dc-rank': rankList
    },
    created () {
      this.dataInit();
    },
    data () {
      return {
        routerData: {},
        currentTitle: '退单详情',
        rankKey: ['foodName', 'foodSalesVolume'],
        rankTitles: [],
        param: {},
        url: ''
      };
    },
    activated () {
      this.dataInit();
      this.$refs.saleRank.changeList();
    },
    methods: {
      dataInit () {
        this.routerData = this.$route.query;
        if (this.routerData) {
          this.param = {
            timeFlag: this.routerData.currentDate.type,
            beginTime: this.routerData.currentDate.startTime,
            endTime: this.routerData.currentDate.endTime,
            mny: this.routerData.mny
          };
        }
        if (this.routerData.num === 2) {
          this.currentTitle = '返位详情';
          this.url = 'getRiskReturnCharge';
          this.rankKey = ['cancelReason', 'cancelTime'];
          this.rankTitles = [
            {name: '返回原因', isRank: false},
            {name: '返回次数', isRank: false}
          ];
        } else if (this.routerData.num === 3) {
          this.currentTitle = '赠单详情';
          this.url = 'getRiskPresentCharge';
          this.rankKey = ['presentReason', 'presentTime', 'presentNum', 'presentMny', 'presentProp'];
          this.rankTitles = [
            {name: '赠单原因', isRank: false},
            {name: '赠单次数', isRank: false},
            {name: '赠单数量', isRank: false},
            {name: '赠单金额', isRank: false},
            {name: '金额占比', isRank: false}
          ];
        } else if (this.routerData.num === 4) {
          this.currentTitle = '宴请详情';
          this.url = 'getRiskBanquetsCharge';
          this.rankKey = ['zeroReason', 'zeroTime', 'zeroMny', 'zeroProp'];
          this.rankTitles = [
            {name: '宴请原因', isRank: false},
            {name: '宴请次数', isRank: false},
            {name: '宴请金额', isRank: false},
            {name: '金额占比', isRank: false}
          ];
        } else {
          this.currentTitle = '退单详情';
          this.url = 'getRiskBackData';
          this.rankKey = ['returnReason', 'returnTime', 'returnNum', 'returnMny', 'returnProp'];
          this.rankTitles = [
            {name: '退单原因', isRank: false},
            {name: '退单次数', isRank: false},
            {name: '退单数量', isRank: false},
            {name: '退单金额', isRank: false},
            {name: '金额占比', isRank: false}
          ];
        }
      }
    }
  };
</script>
<style lang="scss" scoped>
</style>
